{include file="common/header"/}
<style>
.hide{
    display: none;
}
</style>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-col-md12">
        <div class="layui-card">
          <div class="layui-card-body">

          	<form class="layui-form layui-form-pane" lay-filter="form">
            <div class="layui-form-item">
                <label class="layui-form-label">公众号</label>
                <div class=" layui-input-inline " id="box_catid">
                    <select id="wx_id" lay-verify="required" lay-filter="checkChannel" name="wx_id">
                        {volist name="wechat" id="vo"}
                            <option value="{$vo.id}">{$vo.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="layui-form-mid layui-word-aux red">*必填</div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">关 键 字</label>
                <div class=" layui-input-inline">
                    <input type="text" name="keys" lay-verify="required" placeholder="请输入关键字" class="layui-input"> 
                </div>
                <div class="layui-form-mid layui-word-aux red">*必填</div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">规则状态</label>
                <div class=" layui-input-inline ">
                    <input name="status" checked value="1" type="radio" title="启用">
                    <input name="status" value="0" type="radio" title="禁用">                                  
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">消息类型</label>
                <div class=" layui-input-inline">
                {foreach $msgTypes as $k=>$v}
                <!--{if (!isset($vo.type) and $k eq 'text') or (isset($vo.type) and$vo.type eq $k)}-->
                    <input name="msgtype" lay-filter="msgtype" checked value="{$k}" type="radio" title="{$v}">
                <!--{else}-->
                    <input name="msgtype" lay-filter="msgtype" value="{$k}" type="radio" title="{$v}">
                <!--{/if}-->
                {/foreach}                      
                </div>
            </div>

            <div class="layui-form-item msgtype hide text">
                <label class="layui-form-label">回复内容</label>
                <div class=" layui-input-inline">
                    <textarea name="content" placeholder="" class="layui-textarea">说点什么吧</textarea> 
                </div>
            </div>
            <div class="layui-form-item msgtype hide news">
                <label class="layui-form-label">选择图文</label>
                <div class="layui-input-inline">
                    <input type="hidden" name="news_id" value="0">
                    <button class="layui-btn" id="selectNews" type="button">选择图文</button>
                </div>
            </div>
            <div class="layui-form-item msgtype hide image">
                <label class="layui-form-label">图片地址</label>
                <div class="layui-input-inline">
                    <input type="hidden" name="image_url" id="image_url" class="attach">
                    <div class="layui-upload">
                        <button type="button" class="layui-btn layui-btn-primary" id="selectAttach" data-href="{:url('sys.attach/select')}?mime=image"><i class="icon icon-upload3"></i>选择</button>
                        <div class="layui-upload-list">
                            <img class="layui-upload-img" style="width:120px;max-height:100px;" id="muThumb" src="" title="">
                            <p id="thumbText"></p>
                        </div>
                    </div>                                
                </div>
            </div>
            <!-- <div class="layui-form-item msgtype hide music">
                <label class="layui-form-label">音乐标题</label>
                <div class="layui-input-inline">
                    <input type="text" name="music_title" lay-verify="required" value="音乐标题" class="layui-input"> 
                </div>
                <div class="layui-form-mid layui-word-aux red">*必填</div>
            </div>
            <div class="layui-form-item msgtype hide music">
                <label class="layui-form-label">上传音乐</label>
                <div class="layui-input-inline">
                    <input type="text" name="music_url" value="" class="layui-input"> 
                </div>
                <div class="layui-form-mid layui-word-aux red">*必填</div>
            </div>
            <div class="layui-form-item msgtype hide music">
                <label class="layui-form-label">音乐描述</label>
                <div class="layui-input-inline">
                    <input type="text" name="music_desc" placeholder="音乐描述" class="layui-input"> 
                </div>
            </div>
            <div class="layui-form-item msgtype hide music">
                <label class="layui-form-label">音乐图片</label>
                <div class="layui-input-inline">
                    <input type="text" name="music_image" lay-verify="required" value="{:request()->domain()}/static/admin/images/image.png" class="layui-input"> 
                </div>
                <div class="layui-form-mid layui-word-aux red">*必填</div>
            </div> -->
            
            <!-- 视频 -->
            <!-- <div class="layui-form-item msgtype hide video">
                <label class="layui-form-label">视频标题</label>
                <div class="layui-input-inline">
                    <input type="text" name="video_title" lay-verify="required" value="视频标题" class="layui-input"> 
                </div>
                <div class="layui-form-mid layui-word-aux red">*必填</div>
            </div>
            <div class="layui-form-item msgtype hide video">
                <label class="layui-form-label">上传视频</label>
                <div class="layui-input-inline">
                    <input type="text" name="video_url" value="" class="layui-input"> 
                </div>
            </div>
            <div class="layui-form-item msgtype hide video">
                <label class="layui-form-label">视频描述</label>
                <div class="layui-input-inline">
                    <input type="text" name="video_desc" placeholder="视频描述" class="layui-input"> 
                </div>
            </div> -->
            <!-- 语音 -->
            <!-- <div class="layui-form-item msgtype hide voice">
                <label class="layui-form-label">上传语音</label>
                <div class="layui-input-inline">
                    <input type="text" name="voice_url" placeholder="音乐标题" class="layui-input"> 
                </div>
                <div class="layui-form-mid layui-word-aux red">*必填</div>
            </div>
            <div class="layui-form-item msgtype hide customservice">
                <label class="layui-form-label">回复内容</label>
                <div class=" layui-input-inline">
                    <textarea name="customservice" placeholder="" class="layui-textarea">说点什么吧</textarea> 
                </div>
            </div> -->
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input type="hidden" name="id"  >
                    <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">保存</button>
                </div>
            </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>

{include file="common/footer"/}
<script src="/static/admin/layuiadmin/lib/ace/ace.js"></script>
<script>
var layForm;
var layedit;
var layeditIndex
var info = [];
layui.use(['form', 'layer','upload','layedit'], function(){
    var layer = layui.layer,$= layui.jquery;
    layForm = layui.form;
    var upload = layui.upload;
    info = {:json_encode($info)};
    layForm.val("form", info);
    if(info){
        $('#muThumb').attr('src',info.image_url);
    }
    layForm.render();
    var uploadInst = upload.render({
        elem: '#thumbBtn'
        ,url: '{:url("UpFiles/image")}'
        ,accept: 'images' //普通文件
        ,exts: 'jpg|png|gif' //只允许上传压缩文件
        ,done: function(res){
            $('#muThumb').attr('src',res.url);
            $('#thumb').val(res.url);
            $('.news-left div.mediasList.active [data-select="mediasImg"]').attr('src',res.url);
        }
    });
    // 监听消息事件类型
    layForm.on('radio(msgtype)', function(data){
        var val = data.value
        $('.msgtype').hide();
        $('.'+val).show();
    });  
    $('.'+$('input[name=msgtype]:checked').val()).show();

    $('#selectNews').click(function(){
        var wx_id = $('#wx_id').find('option:selected').val();
        layer.open({
          type: 2,
          title: '选择图文',
          shade: 0,
          maxmin: true,
          skin: 'layui-layer-rim',
          area: ['800px','600px'], //宽高
          content: '{:url("wechat.wxmaterial/getlist")}?wx_id='+wx_id,
        });
    })
});
</script>